Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pricing options flexibility #2504

Merged
merged 3 commits into from
Feb 8, 2019

Conversation

softr8
Copy link
Contributor

@softr8 softr8 commented Jan 15, 2018

The last piece, I think, to make pricing options totally flexible is to allow how it's built from a view context, allowing developers to decide how to find the prices based, example: users role

It also adjusts the API to use object.price_for(current_pricing_options)

I can add tests if you think this is a good idea.

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good addition to the API. Please do add some specs.

@softr8 softr8 force-pushed the feature/improve-pricing-options branch from 2329719 to 6626470 Compare January 16, 2018 22:44
subject { described_class.from_context(view_context) }

context "if the store has not defined default_currency" do
let(:store) { FactoryBot.create :store, default_currency: nil , cart_tax_country_iso: nil}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space found before comma.
Space missing inside }.

@@ -68,6 +68,29 @@
end
end

context ".from_context" do
let(:view_context) { double(ApplicationController, current_store: store)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing inside }.

@softr8 softr8 force-pushed the feature/improve-pricing-options branch from 6626470 to 73a3bcc Compare January 16, 2018 22:51
@softr8
Copy link
Contributor Author

softr8 commented Jan 16, 2018

Done @mamhoff, let me know what you think now... Thanks!

@mamhoff
Copy link
Contributor

mamhoff commented Jan 17, 2018

Looks good, but can you look into the failing spec?

@mamhoff
Copy link
Contributor

mamhoff commented Jan 19, 2018

Hm. The spec failure fix makes me wary. Why do the first two commits change the return value of variant.default_price? If we break that method, many admin views will cease to function.

@softr8
Copy link
Contributor Author

softr8 commented Jan 19, 2018

Actually, the failing spec was a test that sometimes fails, I saw it red in other PR's. My guess is that a simple rebuild would've made it green.

I didn't change default_price method at all, the reason I changed the form was because we have an external job that imports prices in bulk from a Google SpreadSheet, and if a variant didn't have any price yet, the variant edition was breaking, that's why I used find or build.

@softr8
Copy link
Contributor Author

softr8 commented Jan 30, 2018

Any comment @mamhoff ? I can rollback the view change if you feel it is not that safe.

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. Go for it.

@softr8 softr8 force-pushed the feature/improve-pricing-options branch from 3b365ab to 9ebda2f Compare February 22, 2018 10:49
@softr8 softr8 force-pushed the feature/improve-pricing-options branch from 9ebda2f to 1606b79 Compare August 8, 2018 15:23
subject { described_class.from_context(view_context) }

context "if the store has not defined default_currency" do
let(:store) { FactoryBot.create :store, default_currency: nil , cart_tax_country_iso: nil }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceBeforeComma: Space found before comma.

@softr8 softr8 force-pushed the feature/improve-pricing-options branch from 1606b79 to 051e470 Compare August 8, 2018 15:24
@softr8 softr8 force-pushed the feature/improve-pricing-options branch from 051e470 to f34064b Compare October 17, 2018 15:53
@kennyadsl
Copy link
Member

@jtapia Hey I think this is a great change, can you please rebase against master?

@spaghetticode
Copy link
Member

@softr8 thanks for this PR 👏
Can you please rebase this with current master?

@softr8 softr8 force-pushed the feature/improve-pricing-options branch from f34064b to dc40bc9 Compare February 4, 2019 21:16
@softr8
Copy link
Contributor Author

softr8 commented Feb 4, 2019

Rebased!

Copy link
Contributor

@jacobherrington jacobherrington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @softr8!

@kennyadsl kennyadsl merged commit dae0e9a into solidusio:master Feb 8, 2019
@kennyadsl
Copy link
Member

Thanks @softr8 !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants